/*这是创建vuex的store*/
import Vue from "vue";
import Vuex from "vuex";
import menus from "@/store/menus";
Vue.use(Vuex);
export { mergeRoutesByMenuCode };

function mergeRoutesByMenuCode(vueRoutes,phpRoutes) {

    // phpRoutes.forEach(phpRoute => {
    //     const vueRoute = vueRoutes.find(vueRoute => {
    //         console.log('vueRoute',vueRoute)
    //         const vueMenuCode = vueRoute.meta ? vueRoute.meta.menu_code : '';
    //         const phpMenuCode = phpRoute.meta ? phpRoute.meta.menu_code : '';
    //         return vueMenuCode === phpMenuCode;
    //     });
    //
    //     if (vueRoute) {
    //         vueRoute.meta = phpRoute.meta;
    //         vueRoute.children = phpRoute.children;
    //     }
    // });
    const newRoutes = [];
    phpRoutes.forEach(phpRoute => {
        vueRoutes.forEach(vueRoute => {
            if (vueRoute.meta && vueRoute.meta.menu_code === phpRoute.menu_code) {
                newRoutes.push(vueRoute);
            }
        });
    });
    // console.log('newRoutes',newRoutes);
    return newRoutes;
}



export default new Vuex.Store({
    modules: {
        menus
    }
})